package com.zhongchaowuye.beans;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.zhongchaowuye.filter.WebFilter;

/**
 * @program: 中超物业（excel系统）
 * @author：张雁佳
 * @create: 2024-11-20
 * @description: 拦截器对象的定义
 */
@Configuration
public class FilterBeans {
    //拦截器定义（web端）
    @Bean
    public FilterRegistrationBean setWebFilter() {
        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setFilter(new WebFilter());
        String[] patterns = new String[]{//如有补充，使用“逗号+地址串”的方式（如：,"/car/*"）
                "/web/*",
                "/car/*" 
        };
        //registration.addUrlPatterns("/*");//设置过滤路径，可以直接写入参数中，如"/getUser","/hello"
        registration.addUrlPatterns(patterns);//也可以将数组带入
        registration.setName("webFilter");
        //拦截优先级设置
        registration.setOrder(2);
        return registration;
    }
}
